/**
* Created by wust on 2020-07-09 08:53:20.
*/
<template>
	<el-form ref="formModel" :model="formModel" :rules="rules" label-width="120px" style="width:70%;"
	 @submit.native.prevent>
		<el-form-item label="login_name" prop="loginName">
			<el-input v-model="formModel.loginName"></el-input>
		</el-form-item>
		<el-form-item label="name" prop="name">
			<el-input v-model="formModel.name"></el-input>
		</el-form-item>
		<el-form-item label="sex" prop="sex">
			<el-input v-model="formModel.sex"></el-input>
		</el-form-item>
		<el-form-item label="type" prop="type">
			<el-input v-model="formModel.type"></el-input>
		</el-form-item>
		<el-form-item label="apply_status" prop="applyStatus">
			<el-input v-model="formModel.applyStatus"></el-input>
		</el-form-item>
		<el-form-item label="mobile_phone" prop="mobilePhone">
			<el-input v-model="formModel.mobilePhone"></el-input>
		</el-form-item>
		<el-form-item label="telephone" prop="telephone">
			<el-input v-model="formModel.telephone"></el-input>
		</el-form-item>
		<el-form-item label="email" prop="email">
			<el-input v-model="formModel.email"></el-input>
		</el-form-item>
		<el-form-item label="ID_number" prop="idNumber">
			<el-input v-model="formModel.idNumber"></el-input>
		</el-form-item>
		<el-form-item label="status" prop="status">
			<el-input v-model="formModel.status"></el-input>
		</el-form-item>
		<el-form-item label="description" prop="description">
			<el-input v-model="formModel.description" type="textarea" :rows="6">
			</el-input>
		</el-form-item>
		<el-form-item style="text-align: left;">
			<el-button type="primary" @click="onSubmit('formModel')" :loading="submitting">提交</el-button>
		</el-form-item>
	</el-form>
</template>
<script>
import Vue from 'vue'

export default {
  name: 'customer-update',
  props: ['selectedModel'],
  data () {
    return {
      submitting: false,
      formModel: {
        id: null,
        loginName: null,
        name: null,
        sex: null,
        type: null,
        applyStatus: null,
        mobilePhone: null,
        telephone: null,
        email: null,
        idNumber: null,
        status: null,
        description: null,
        agentId: null,
        parentCompanyId: null,
        branchCompanyId: null

      },
      rules: {}
    }
  },
  created: function () {
    this.formModel = this.selectedModel
  },
  methods: {
    onSubmit: function (formData) {
      this.$refs[formData].validate((valid) => {
        if (!valid) {} else {
          Vue.$ajax({
            method: 'put',
            url: Vue.$adminServerURL + '/web/v1/CustomerController',
            data: this.formModel
          }).then(res => {
            if (res.data.flag !== 'SUCCESS') {
              if (!Vue.$isNullOrIsBlankOrIsUndefined(res.data.message)) {
                this.$message({
                  message: res.data.message,
                  type: 'warning'
                })
              }
            } else {
              this.$message({
                message: res.data.message,
                type: 'success'
              })
            }
          })
        }
      })
    }
  }
}
</script>
